<template>
    <div>
        <Poptip trigger="hover">
            <template #content >
                <Avatar shape="square" :src='tempAvatar' >{{tempName.substr(0,2)}}</Avatar>
                {{tempName}}
                <br />
                <br />
                <ButtonGroup >
                    <Button type="primary" size='small'>
                        访问主页
                    </Button>
                    <Button type="primary" size='small'>
                        ＋关注
                    </Button>
                </ButtonGroup>
            </template>
            <Avatar :src='tempAvatar' >{{tempName.substr(0,2)}}</Avatar>
            {{tempName}}
        </Poptip>
    </div>
</template>
<script>
import tePic from '@//assets/001.jpg'
export default {
    name:'userSpan',
    props:{
        id:{
            type:String,
        },
        name:{
            type:String,
        },
        avatar:{
            tyep:String,
        }
    },
    data(){
        return {
            tempName:this.name||"未知",
            tempAvatar:this.avatar||tePic,
        }
    },
    mounted(){
        if(!this.name&&this.id){
            this.$post('/user/getById',this.id).then(res=>{
                this.tempName = res.name||"未知";
                this.tempAvatar = res.avatar;
            }).catch(err=>{

            });
        }
    }
}
</script>

